/*
    api:"查询职位类型"
    name:"陈小洋"
    time：2021.1.24
* */
const PostType = require('../../../control/PostType/PostType')
const tools = require('../../../tools/public');
/**
 * @api {post} /postType/delPostType 3.删除职位类型
 * @apiGroup PostType
 *
 * @apiParam {Number} level 删除的数据所属的职位层级
 * @apiParam {String} _id   职位id
 * @apiParam {String} [parentId] 父级id
 *
 * @apiParamExample {json} Request-Example
 *{
 *
 *}
 * @apiSuccessExample  {json} Response-Example
 * {
 *   "code": 200,
 *   "msg": "删除成功！"
 *   }
 */
module.exports = async function (req, res, next) {
    let {level, _id, parentId} = req.body, result = null;
    try {
        if (!level) return res.send(tools.ReturnData(204, '参数错误,请认真阅读接口文档！'));
        if(Number(level)===1){
            result = await PostType.Del_One_ById_forLevel1(_id)
            return res.send(tools.ReturnData(200, '删除成功！',result));
        }else if(Number(level)===2){
            result = await PostType.Del_One_ById_forLevel2(_id,parentId)
            return res.send(tools.ReturnData(200, '删除成功！',result));
        }else{
            return res.send(tools.ReturnData(205, '其他错误！',result));
        }


    } catch (e) {
        console.log(e)
        return res.send(tools.ReturnData(500, '系统内部错误！'));
    }
};